from django.db import models


class DouyinAweme(models.Model):
    user_id = models.CharField(max_length=64, null=True, blank=True, verbose_name='用户ID')
    sec_uid = models.CharField(max_length=128, null=True, blank=True, verbose_name='用户sec_uid')
    short_user_id = models.CharField(max_length=64, null=True, blank=True, verbose_name='用户短ID')
    user_unique_id = models.CharField(max_length=64, null=True, blank=True, verbose_name='用户唯一ID')
    nickname = models.CharField(max_length=64, null=True, blank=True, verbose_name='用户昵称')
    avatar = models.CharField(max_length=255, null=True, blank=True, verbose_name='用户头像地址')
    user_signature = models.CharField(max_length=500, null=True, blank=True, verbose_name='用户签名')
    ip_location = models.CharField(max_length=255, null=True, blank=True, verbose_name='评论时的IP地址')
    add_ts = models.BigIntegerField(verbose_name='记录添加时间戳')
    last_modify_ts = models.BigIntegerField(verbose_name='记录最后修改时间戳')
    aweme_id = models.CharField(max_length=64, verbose_name='视频ID', unique=True)
    aweme_type = models.CharField(max_length=16, verbose_name='视频类型')
    title = models.CharField(max_length=1024, null=True, blank=True, verbose_name='视频标题')
    desc = models.TextField(verbose_name='视频描述')
    create_time = models.BigIntegerField(verbose_name='视频发布时间戳')
    liked_count = models.CharField(max_length=16, null=True, blank=True, verbose_name='视频点赞数')
    comment_count = models.CharField(max_length=16, null=True, blank=True, verbose_name='视频评论数')
    share_count = models.CharField(max_length=16, null=True, blank=True, verbose_name='视频分享数')
    collected_count = models.CharField(max_length=16, null=True, blank=True, verbose_name='视频收藏数')
    aweme_url = models.CharField(max_length=255, null=True, blank=True, verbose_name='视频详情页URL')
    source_keyword = models.CharField(max_length=255, default='', verbose_name='搜索来源关键字')
    task_id = models.CharField(max_length=255, verbose_name='任务ID', null=True, blank=True)
    class Meta:
        db_table = 'douyin_aweme'
        verbose_name = '抖音视频'
        indexes = [
            models.Index(fields=['aweme_id'], name='idx_douyin_awem_aweme_i_6f7bc6'),
            models.Index(fields=['create_time'], name='idx_douyin_awem_create__299dfe'),
        ]


class DouyinAwemeComment(models.Model):
    user_id = models.CharField(max_length=64, null=True, blank=True, verbose_name='用户ID')
    sec_uid = models.CharField(max_length=128, null=True, blank=True, verbose_name='用户sec_uid')
    short_user_id = models.CharField(max_length=64, null=True, blank=True, verbose_name='用户短ID')
    user_unique_id = models.CharField(max_length=64, null=True, blank=True, verbose_name='用户唯一ID')
    nickname = models.CharField(max_length=64, null=True, blank=True, verbose_name='用户昵称')
    avatar = models.CharField(max_length=255, null=True, blank=True, verbose_name='用户头像地址')
    user_signature = models.CharField(max_length=500, null=True, blank=True, verbose_name='用户签名')
    ip_location = models.CharField(max_length=255, null=True, blank=True, verbose_name='评论时的IP地址')
    add_ts = models.BigIntegerField(verbose_name='记录添加时间戳')
    last_modify_ts = models.BigIntegerField(verbose_name='记录最后修改时间戳')
    comment_id = models.CharField(max_length=64, verbose_name='评论ID')
    aweme_id = models.ForeignKey(
        DouyinAweme,
        to_field='aweme_id',
        db_column='aweme_id',
        on_delete=models.CASCADE,
        related_name='comments',
        verbose_name='视频关联',
        null=True,
        blank=True,
    )
    content = models.TextField(verbose_name='评论内容')
    create_time = models.BigIntegerField(verbose_name='评论时间戳')
    sub_comment_count = models.CharField(max_length=16, verbose_name='评论回复数')
    parent_comment_id = models.CharField(max_length=64, null=True, blank=True, verbose_name='父评论ID')
    like_count = models.IntegerField(default=0, verbose_name='点赞数')

    class Meta:
        db_table = 'douyin_aweme_comment'
        verbose_name = '抖音视频评论'
        indexes = [
            models.Index(fields=['comment_id'], name='idx_douyin_awem_comment_fcd7e4'),
            models.Index(fields=['aweme_id'], name='idx_douyin_awem_aweme_i_c50049'),
        ]


class DyCreator(models.Model):
    user_id = models.CharField(max_length=128, verbose_name='用户ID')
    nickname = models.CharField(max_length=64, null=True, blank=True, verbose_name='用户昵称')
    avatar = models.CharField(max_length=255, null=True, blank=True, verbose_name='用户头像地址')
    ip_location = models.CharField(max_length=255, null=True, blank=True, verbose_name='评论时的IP地址')
    add_ts = models.BigIntegerField(verbose_name='记录添加时间戳')
    last_modify_ts = models.BigIntegerField(verbose_name='记录最后修改时间戳')
    desc = models.TextField(verbose_name='用户描述')
    gender = models.CharField(max_length=2, null=True, blank=True, verbose_name='性别')
    follows = models.CharField(max_length=16, null=True, blank=True, verbose_name='关注数')
    fans = models.CharField(max_length=16, null=True, blank=True, verbose_name='粉丝数')
    interaction = models.CharField(max_length=16, null=True, blank=True, verbose_name='获赞数')
    videos_count = models.CharField(max_length=16, null=True, blank=True, verbose_name='作品数')
    task_id = models.CharField(max_length=255, verbose_name='任务ID', null=True, blank=True)
    class Meta:
        db_table = 'dy_creator'
        verbose_name = '抖音博主信息'
